<template>
    <div class="contentWeb clear">
        <div class="member_menu">
            <Memleft active=""/>
        </div>
        <div class="member_right">

            <div class="none_mem" v-if="!info.sex">
                <div style="padding-bottom: 70px;" class="clear">
                    <img :src="nonoe" class="noneimg">
                    <p>你尚未添加线上简历</p>
                    <div v-if="!curUserInfo.elAppls || curUserInfo.elAppls == 2" class="btns" @click="tomyjianli()">添加简历</div>
                </div>
            </div>
            <div class="myjianli clear" v-else>
                <div class="jianliLeft">
                    <div class="clear">
                        <img :src="info.headerUrl ? info.headerUrl : tx" class="tx">
                        <div class="jianNames" @click="tomyjianli">
                            <h2>{{info.name}}的简历</h2>
                            <p>更新于{{info.updateTime}}</p>
                        </div>
                        <div class="morelook">
                          <button class="jizhi" v-if="info.jlzt != 1">已禁用</button>
                          <el-tag v-else-if="info.approval == 1" type="warning">审核中</el-tag>
                          <el-tag v-else-if="info.approval == 3" type="danger">审核不通过</el-tag>
                        </div>
                    </div>
                    <el-alert v-if="info.jlzt != 1"
                      :closable="false" style="margin-top: 20px;"
                      :title="info.jzyy"
                      type="error" >
                    </el-alert>
                    <el-alert v-else-if="info.approval == 3"
                      :closable="false" style="margin-top: 20px;"
                      :title="info.jzyy || '审核不通过'"
                      type="error" >
                    </el-alert>
                    <el-row :gutter="20" class="teshunum" style="margin-top: 20px;">
                        <el-row :gutter="10">
                            <el-col :span="8">
                                <div class="qynum">

                                    <h2>{{infoNum.watch}}</h2>
                                    <p>被看过</p>
                                </div>
                            </el-col>
                            <el-col :span="8">
                                <div class="jobnum">

                                    <h2>{{infoNum.apply}}</h2>
                                    <p>我申请的</p>
                                </div>
                            </el-col>
                            <el-col :span="8">
                                <div class="rennum">

                                    <h2>{{infoNum.collection}}</h2>
                                    <p>我收藏的</p>
                                </div>
                            </el-col>
                        </el-row>
                    </el-row>
                </div>
                <div class="jianliRight">
                    <div class="btns" @click="researh"><img :src="m_shuaxin"><span>刷新</span></div>
                    <div class="btns" @click="lookview"><img :src="m_yulan"><span>预览</span></div>
                    <div v-if="info.approval != 1" class="btns" @click="tomyjianli"><img :src="m_edit"><span>编辑</span></div>
                </div>
            </div>
            <div v-if="Object.keys(info).length > 0">
                <div class="membt">最近看过我的企业</div>  <!--只显示3条效果图上没有分页-->

                <el-row :gutter="20">
                     <el-col :span="8" v-for="(item, index) in ListList" :key="index">
                        <div class="historytab" @click="toCompany(item)">
                            <div class="clear">
                                <img :src="item.logo">
                                <div class="names">
                                    <h2>{{item.enterpriseName}}</h2>
                                    <div class="desc"><span>{{item.enterpriseNature}}</span><span>{{item.industry}}</span></div>
                                </div>
                            </div>
                            <div class="times">查看时间 {{item.watchTime}}</div>
                        </div>
                    </el-col>
                </el-row>

            </div>
        </div>
    </div>
</template>
<script type="text/babel">
// @ is an alias to /src
import m_shuaxin from '../../assets/img/m_shuaxin.png'
import m_yulan from '../../assets/img/m_yulan.png'
import m_edit from '../../assets/img/m_edit.png'
import tx from '../../assets/img/default.jpg'
import mt from '../../assets/img/mt.png'
import Memleft from '../../components/memleft'
import nonoe from '../../assets/img/weijian.png'
import { CVBaseInfo, JobFairQuantity, WhoWatchMeByPage, updatePersonalCVInfo, showMyCv } from '../../assets/js/domains'

export default {
  name: 'Member',
  components: { Memleft },
  directives: {},
  data: function () {
    return {
      info: {},
      infoNum: {},
      mt: mt,
      nonoe: nonoe,
      tx: tx,
      m_shuaxin: m_shuaxin,
      m_yulan: m_yulan,
      m_edit: m_edit,
      search: {
        pageNum: 1, pageSize: 3, user_uid: ''
      },
      ListList: [],
      count: 0
    }
  },
  created: function () {
    document.documentElement.scrollTop = document.body.scrollTop = 0
    this.userUid = localStorage.getItem('md_user_uid')
    if (!this.userUid) {
      this.$alert('您还没有登录', '提示', {
        confirmButtonText: '确定',
        callback: function () {
          window.location.href = 'index.html'
        }
      })
      return false
    }
  },
  computed: {},
  mounted: function () {
    this.getpost()
    this.getPeopleJobFair()
    this.getWhoWatchMeByPage()
  },
  methods: {
    getPeopleJobFair: function () {
      const _this = this
      showMyCv({ user_uid: this.userUid }).then(function (res) {
        if (res.code === 200) {
          _this.infoNum = res.data
        }
      })
    },
    researh: function () {
      updatePersonalCVInfo({ userUid: this.userUid }).then(res => {
        if (res.code === 200) {
          this.$message.success('简历刷新成功')
          this.info = res.data || {}
          // this.info.updateTime = res.data;
        }
      })
    },
    lookview: function () {
      window.location.href = '/personResume.html'
    },
    tomyjianli: function () {
      window.location.href = '/personInfo.html'
    },
    toCompany (company) {
      window.location.href = '/companyDetail.html?enterpriseUid=' + company.enterpriseUid
    },
    getWhoWatchMeByPage: function () {
      var _this = this
      _this.search.user_uid = this.userUid
      WhoWatchMeByPage(_this.search).then(function (res) {
        if (res.code === 200) {
          _this.ListList = res.data.content
          _this.count = res.data.totalElements
        }
      })
    },
    getpost: function () {
      const _this = this
      this.userUid = localStorage.getItem('md_user_uid')
      if (!this.userUid) {
        return false
      }
      CVBaseInfo({ user_uid: this.userUid }).then(function (res) {
        if (res.code === 200) {
          _this.info = res.data || {}
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
    @import "../../assets/css/member";
</style>
